import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import ProfileEdit from '@/views/ProfileEdit.vue'

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      redirect: '/profile'
    },
    {
      path: '/profile',
      component: ProfileEdit,
      meta: { title: '个人资料' }
    },
    {
      path: '/address',
      component: () => import('@/views/AddressManager.vue'),
      meta: { title: '地址列表' }
    },
    {
      path: '/address/edit/:id?',
      component: () => import('@/views/AddressEdit.vue'),
      meta: { title: '地址详情' }
    }
  ]
})

router.afterEach((to) => {
  document.title = to.meta.title as string
})

export default router
